package day02;

public class Demo10 {

	public static void main(String[] args) {
		Point p1=new Point(3,4);
		Point p2=new Point(5,6);
		Point p3=new Point(3,4);
		Point p4=p1;
		System.out.println(p1==p3);
		System.out.println(p1==p4);
		System.out.println(p1.equals(p3));
		
		
	}

}


class Point {
	int x,y;
	Point(int x,int y){
		this.x=x;
		this.y=y;
		
	}
	public String toString(){
		return x+","+y;
	}
	
//	public boolean equals(Point p){
//	
//		return (p.x==this.x)&&(p.y==this.y);
//		
//	}

	//-------------------------------
	
	
	
	public boolean equals(Object obj){
		if(obj==null) return false;
		if(this==obj) return true;
		if(obj instanceof Point){
			Point p=(Point)obj;
			return this.x==p.x&&this.y==p.y;
		}
		return false;
		
	}
	
	
	
	
}